package com.tle.eventexample;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import com.tle.libs.CONSTANTS.FONT_PATHS;
import com.tle.libs.CONSTANTS.TEXT_SIZES;
import com.tle.libs.UIUtilities;


public class MainActivity extends BaseActivity 
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Properties //
	////////////////////////////////////////////////////////////////////////////////////////////////////
	protected Button m_btnCalculator;
	protected Button m_btnConvertYear;
	protected Button m_btnCalculateBMI;
	protected Button m_btnSolveQuadraticEquation;
	protected Button m_btnUsingCheckboxAndRadio;
	protected Button m_btnSetting;
	protected Button m_btnQuit;
	
	protected LinearLayout m_mainLayout;
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
																						// Properties //
	////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Constructor and Support Method //
	////////////////////////////////////////////////////////////////////////////////////////////////////
	
	protected void setActivityTitle() 
	{
		this.setTitle(R.string.app_name);
	};
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		this.initGUI();
		UIUtilities.setUIStandard(m_mainLayout , FONT_PATHS.SEMI_BOLD, TEXT_SIZES.MAX);
		this.registerEvent();
	}
	
	protected void initGUI ()
	{
		this.setTitle(R.string.app_name);
		
		ScrollView scrollView = new ScrollView(this);
		scrollView.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) );
		this.setContentView(scrollView);
		
		m_mainLayout = new LinearLayout(this);
		scrollView.addView(m_mainLayout);
		
		m_mainLayout.setOrientation(LinearLayout.VERTICAL);
		m_mainLayout.setGravity(Gravity.CENTER_HORIZONTAL);
		
		
		
		this.buildMenuButtons();
	}
	
	protected void buildMenuButtons ()
	{
		m_btnCalculator = new Button(this);
		m_mainLayout.addView(m_btnCalculator);
//		m_btnCalculator.setText(R.string.title_Calculator);
		
		
		
		m_btnConvertYear = new Button(this);
		m_mainLayout.addView(m_btnConvertYear);
//		m_btnConvertYear.setText(R.string.title_Converter);
		
		
		
		m_btnCalculateBMI = new Button(this);
		m_mainLayout.addView(m_btnCalculateBMI);
//		m_btnCalculateBMI.setText(R.string.title_BMICalculator);
		
		
		
		m_btnSolveQuadraticEquation = new Button(this);
		m_mainLayout.addView(m_btnSolveQuadraticEquation);
//		m_btnSolveQuadraticEquation.setText(R.string.title_QuadraticEquation);
		
		
		
		m_btnUsingCheckboxAndRadio = new Button(this);
		m_mainLayout.addView(m_btnUsingCheckboxAndRadio);
//		m_btnUsingCheckboxAndRadio.setText(R.string.title_UsingCheckboxAndRadio);
		
		
		
		m_btnSetting = new Button(this);
		m_mainLayout.addView(m_btnSetting);
//		m_btnSetting.setText(R.string.title_Setting);
		
		
		
		m_btnQuit = new Button(this);
		m_mainLayout.addView(m_btnQuit);
//		m_btnQuit.setText(R.string.title_Exit);
		
		this.updateLanguage();
	}
	
	protected void registerEvent ()
	{
		ButtonEvent buttonEvent = new ButtonEvent();
		m_btnCalculator.setOnClickListener(buttonEvent);
		m_btnCalculateBMI.setOnClickListener(buttonEvent);
		m_btnConvertYear.setOnClickListener(buttonEvent);
		m_btnSolveQuadraticEquation.setOnClickListener(buttonEvent);
		m_btnUsingCheckboxAndRadio.setOnClickListener(buttonEvent);
		m_btnSetting.setOnClickListener(buttonEvent);
		m_btnQuit.setOnClickListener(buttonEvent);
	}
	
	
	
	protected void updateLanguage ()
	{
		m_btnCalculator.setText(R.string.title_Calculator);
		m_btnConvertYear.setText(R.string.title_Converter);
		m_btnCalculateBMI.setText(R.string.title_BMICalculator);
		m_btnSolveQuadraticEquation.setText(R.string.title_QuadraticEquation);
		m_btnUsingCheckboxAndRadio.setText(R.string.title_UsingCheckboxAndRadio);
		m_btnSetting.setText(R.string.title_Setting);
		m_btnQuit.setText(R.string.title_Exit);
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
																	// Constructor and Support Method //
	////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Support class and methods //
	////////////////////////////////////////////////////////////////////////////////////////////////////
	private class ButtonEvent implements OnClickListener
	{
		@Override
		public void onClick(View v) 
		{
			// TODO Auto-generated method stub
			if (v == m_btnCalculator)
			{
				Intent intent = new Intent(MainActivity.this, Calculator.class);
				startActivity(intent);
				
			}// end m_btnCalculator
			
			else if (v == m_btnConvertYear)
			{
				Intent intent = new Intent(MainActivity.this, Converter.class);
				startActivity(intent);
			}// end m_btnConvertYear
			
			else if (v == m_btnQuit)
			{
				UIUtilities.showQuitDialog(MainActivity.this);
				
			}// end m_btnQuit
			
			else if (v == m_btnCalculateBMI)
			{
				Intent intent = new Intent(MainActivity.this, BMI.class);
				startActivity(intent);
			}// end m_btnCalculateBMI
			
			else if (v == m_btnSolveQuadraticEquation)
			{
				Intent intent = new Intent(MainActivity.this, QuadraticEquation.class);
				startActivity(intent);
			}// end m_btnSolveQuadraticEquation
			
			else if (v == m_btnUsingCheckboxAndRadio)
			{
				Intent intent = new Intent(MainActivity.this, UsingCheckboxAndRadio.class);
				startActivity(intent);
			}// end m_btnUsingCheckboxAndRadio
			
			else if (v == m_btnSetting)
			{
//				Intent intent = new Intent(MainActivity.this, Setting.class);
				Intent intent = new Intent(MainActivity.this, cls)
				startActivity(intent);
			}// end m_btnSetting
			
		}
	}
	////////////////////////////////////////////////////////////////////////////////////////////////////
																		 // Support class and methods //
	////////////////////////////////////////////////////////////////////////////////////////////////////
}
